const app = getApp();
Page({
  /**
   * 页面的初始数据
   */
  data: {
    userInfo: null,
    myCourseList: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    const that = this;
    wx.getSetting({
      success(res) {
        if (res.authSetting['scope.userInfo']) {
          wx.getUserInfo({
            success: res => {
              app.globalData.userInfo = res.userInfo;
              that.setData({
                userInfo: res.userInfo
              })
            }
          })
        }
      }
    });
    
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
    //查找我的预约记录
    const that = this;
    const openId = app.globalData.openId;
    const memberLogin = app.globalData.memberLogin;
    const url = app.globalData.url;
    wx.request({
      url: url + '/appointment/getTraineeAppointment/' + openId,
      success: function (response) {
        if (response.data.success) {
          const myCourseList = response.data.content;
          that.setData({
            myCourseList,
            memberLogin
          });
        }
      }
    })
  },
  toAppointment: function() {
    wx.switchTab({
      url: '/pages/coach/coach',
    })
  },
  memberLogin:function(){
    wx.navigateTo({
      url: '/pages/memberLogin/memberLogin',
    })
  }
})